草庐IT

android mediaRecorder.setAudioSource 失败

全部标签

go - 一个go代码程序后台运行失败

后台运行的Go代码我是go语言的初学者。我写了一个发出键盘声音的小程序。gobuildmain.go后,可以在当前shell中听到按钮的声音。但是当在后台运行./main或重新打开一个新的shell时,将听不到按钮的声音。这就是我需要帮助的地方。packagemainimport("fmt""github.com/eiannone/keyboard""github.com/faiface/beep""github.com/faiface/beep/speaker""github.com/faiface/beep/wav""os""time""log""path/filepath")fu

Docker 构建因本地 go 包导入而失败

我构建了一个go应用程序,它有一个主包和一个身份验证包。身份验证包在主文件中导入。目录结构如下,docker文件内容如下,FROMgolangCOPY.//Users/venkat/go/src/github.com/Athavankanapuli/interflow_api/loginservice/appWORKDIR/Users/venkat/go/src/github.com/Athavankanapuli/interflow_api/loginservice/appRUNgogetgithub.com/go-kit/kit/endpointRUNgogetgolang.org

go - 使用 JSON 的 POST 调用失败

这个问题在这里已经有了答案:Unmarshallingjsoningolang(1个回答)关闭4年前。我有一个接受这样的请求主体的API:内容类型是application/json。{"firstname":"foo","surname":"bar","age":10,"group":"test"}当我使用像Postman这样的客户端时,请求会通过。但是,来自Go的相同请求失败了:typeStudentstruct{firstnamestringsurnamestringageintgroupstring}student:=Student{"foo","bar",10,"test"}b

go - 我的 bcrypt 密码验证总是失败,说 hashedPassword 不是给定 passwordPASS 的散列

funcvalidateCredentials(attemptedPasswordstring,actualPasswordHashstring)(bool,error){iferr:=bcrypt.CompareHashAndPassword([]byte(actualPasswordHash),[]byte(attemptedPassword));err!=nil{fmt.Printf("validateCredentialserroris%v",err)returnfalse,nil}returntrue,nil}我编写了一个如下所示的测试:funcTestAuth_valida

go - 提示多用户输入失败

关闭。这个问题需要detailsorclarity.它目前不接受答案。想改进这个问题吗?通过editingthispost添加细节并澄清问题.关闭4年前。Improvethisquestionpackagemainimport"fmt"funcmain(){varinStrstringvarinStr2stringfmt.Printf("Input?")fmt.Scanf("%s",&inStr)fmt.Printf("\nOutput:%s\n",inStr)fmt.Printf("Input2?")fmt.Scanf("%s",&inStr2)fmt.Printf("\nOutpu

json - 数组上的 Golang json 解码失败

我有一个像这样的对象:a=[{"name":"rdj","place":"meh","meh":["bow","blah"]}]我定义了这样一个结构:typefirststruct{A[]one}typeonestruct{Placestring`json:"place"`Namestring`json:"name"`}当我在代码中使用相同的代码时:funcmain(){res,_:=http.Get("http://127.0.0.1:8080/sample/")deferres.Body.Close()varsomefirstrd:=json.NewDecoder(res.Body

go - 隐式转换在应该成功的时候失败了?

这个问题在这里已经有了答案:Typeconvertingslicesofinterfaces(9个回答)关闭4年前。我对此非常困惑,我有:funcgetKind(vinterface{})string{rt:=reflect.TypeOf(v)switchrt.Kind(){casereflect.Slice:return"slice"casereflect.Array:return"array"default:return"unknown"}}funcFlattenDeep(args...interface{})[]interface{}{list:=[]interface{}{}f

go - 由于同一包中的 undefined object ,dlv 调试失败

我在delvesite上提交了一个错误.所以,解释一下这是怎么回事。我在同一个包中有2个文件,main.go和common.go。在main.go中,它使用了common.go中的一些结构,当我运行dlvdebug--listen=:2345--headless--api-version=2--logmain.go它因“undefined:NewSimpleStruct”而失败,我不确定我做错了什么。这是Go文件包含的内容,//main.gopackagemainimport("fmt")funcmain(){fmt.Println("HELLOWORLD!")segasaturn:=

unit-testing - 尝试在 TCP 监听器上提供服务时,由于超时,Go 测试模棱两可地失败

我有这个单元测试:funcTestServer(t*testing.T){db:=prepareDBConn(t)deferdb.Close()lis:=bufconn.Listen(1024*1024)t.Logf("Openedlistener:%v",lis)grpcServer:=grpc.NewServer(withUnaryInterceptor(),)t.Logf("Openedgrpcserver:%v",grpcServer)signKey:=getSignKey()ifsignKey==nil{t.Fatal("FailedtofindorparseRSApriva

go - `go get` 命令失败 : unrecognized import path "_/<path>"

基本上,我的问题是,为什么要在我的导入路径前面加一个下划线?它说importpathdoesnotbeginwithhostname我假设这是因为它以下划线开头。我在某处读到这可能与我搞砸了我的GOPATH有关,但我尝试将它移动到任何地方,项目文件夹内、项目文件夹外、默认位置等。我是新来的,最近出现过几次。非常感谢任何指导! 最佳答案 所以我误解了我的源代码应该在哪里。对于同一条船上的任何人,它需要在实际src文件夹中的go路径内。我找到了this有帮助。 关于go-`goget`命令失